<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/demo.js"></script>
    <style>
        .box {
            width: 200px;
            height: 200px;
            background-color: #6ff;
            margin: 50px;
        }
    </style>
</head>

<body>
    <a href="https://www.baidu.com" target="_self">百度</a>
    <div class="box"></div>
    <input type="text">
</body>
<script>
    // 页面相关的事件
    // onload  页面所有内容(文档 js img css)加载完毕
    // onresize 窗口大小改变时执行
    // onscroll 滚动条滚动时执行

    // onfocus   窗口聚焦 (了解)
    // onblur    窗口失焦 (了解)

    // onbeforeunload  离开当前页面时之前 (了解)

    // window.onfocus = function () {
    //     console.log("onfocus", "欢迎访问");
    // }

    // window.onblur = function () {
    //     console.log("onblur", "小菜鸡,是不是想作弊");
    // }

    window.onbeforeunload = function () {
        // alert(1111);
        return "1111";
    }


</script>

</html>